/*
 * Bzip2Demo.java
 * Copyright 2020 Qunhe Tech, all rights reserved.
 * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
 */

package com.lixinlei.tech.type.bzip2;

import com.lixinlei.tech.common.factory.CodecTypeEnum;
import com.lixinlei.tech.common.util.CodecUtils;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

/**
 * Function: Bzip2 编解码示例
 *
 * @author wali
 * @date 2020/10/27
 */
public class Bzip2Demo {

    public static void main(String[] args) throws UnsupportedEncodingException {
        String content = "我是瓦力";
        byte[] encoded = CodecUtils.encode(content.getBytes("UTF-8"), CodecTypeEnum.BZIP2);
        byte[] decoded = CodecUtils.decode(encoded, CodecTypeEnum.BZIP2);
        String decodedString = new String(decoded, Charset.forName("UTF-8"));
        System.out.println(decodedString);
    }

}
